package com.production.CoursePlatform.service;
import com.production.CoursePlatform.entity.Studying;
import com.production.CoursePlatform.mapper.ScheduleMapper;
import com.production.CoursePlatform.mapper.StudyingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;

@Service
public class StudyingService {

    @Autowired
    private StudyingMapper studyingMapper;

    // 添加学习记录
    public int addStudying(Studying studying) {
        // 不指定 `cts_id` 字段
        return studyingMapper.insertWithoutCTSID(studying);
    }

    public int getStudentNumberOfCtID(int ctID){
        return studyingMapper.getStudentNumberOfCtID(ctID);
    }

    // 根据 `cts_id` 删除学习记录
    public int deleteStudying(int cts_id) {
        return studyingMapper.deleteByCTS_ID(cts_id);
    }

    // 更新学习记录
    public int updateStudying(Studying studying) {
        return studyingMapper.updateStudying(studying);
    }

    // 根据 `s_id` 查找学习记录
    public List<Studying> getStudyingBySID(String s_id) {
        return studyingMapper.findBySID(s_id);
    }

    // 获取所有学习记录
    public List<Studying> getAllStudyings() {
        return studyingMapper.selectList(null);
    }
}

